// FullScreenDlg.cpp : implementation file
//

#include "stdafx.h"
#include "m10vc.h"
#include "FullScreenDlg.h"
#include "MVAPI.h"
#include "Common.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFullScreenDlg dialog


CFullScreenDlg::CFullScreenDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFullScreenDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFullScreenDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CFullScreenDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFullScreenDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFullScreenDlg, CDialog)
	//{{AFX_MSG_MAP(CFullScreenDlg)
	ON_WM_LBUTTONDBLCLK()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFullScreenDlg message handlers

void CFullScreenDlg::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	MV_OperateDevice( boardno, MVSTOP );
	CDialog::OnOK();
	CDialog::OnLButtonDblClk(nFlags, point);
}

BOOL CFullScreenDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	int scrnw,scrnh,vdw,vdh;
	DWORD xoffset,yoffset;
	scrnw = GetSystemMetrics(SM_CXSCREEN);
	scrnh = GetSystemMetrics(SM_CYSCREEN);	
	vdw = MV_GetDeviceParameter( boardno, DISP_WIDTH);
	vdh = MV_GetDeviceParameter( boardno, DISP_HEIGHT);
	SetWindowPos(NULL,0,0,scrnw,scrnh,0);
	m_hWhiteBrush.CreateSolidBrush(RGB(255, 255, 255)); 
	m_hBlackBrush.CreateSolidBrush(RGB(0, 0, 0));
	HWND hwnd=GetSafeHwnd();
	MV_SetDeviceParameter( boardno, DISP_WHND, (DWORD)hwnd );
	if(vdw>scrnw)
		xoffset=scrnw&0X0000FFFF;
	else
		xoffset=(scrnw-vdw)/2&0X0000FFFF;
	if(vdh>scrnh)
		yoffset=scrnh&0X0000FFFF;
	else
		yoffset=(scrnh-vdh)/2&0X0000FFFF;
	MV_SetDeviceParameter( boardno, DISP_LEFT, xoffset );
	MV_SetDeviceParameter( boardno, DISP_TOP, yoffset );
    MV_OperateDevice( boardno, MVRUN );
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

HBRUSH CFullScreenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
//	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	if(nCtlColor==CTLCOLOR_DLG)
	{
		pDC->SetBkColor(RGB(0,0,0));
		return m_hBlackBrush;
	}
	else
	{
		pDC->SetBkColor(RGB(255,255,255));
		return m_hWhiteBrush;
	}	
	// TODO: Return a different brush if the default is not desired
//	return hbr;
}
